package com.uniinnovate.lanjingling.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.uniinnovate.lanjingling.entity.JobApplicationEntity;
import com.uniinnovate.lanjingling.service.JobApplicationService;
import com.uniinnovate.lanjingling.utils.PageUtils;
import com.uniinnovate.lanjingling.utils.R;


/**
 * @author LianChuangTech
 * @email LianChuangTech@163.com
 */
@Api(tags = "职位申请相关")
@RestController
@RequestMapping("/lanjingling/jobapplication")
public class JobApplicationController {

    @Autowired
    private JobApplicationService jobApplicationService;

    /**
     * 列表
     */
    @ApiOperation("获取职位申请列表")
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = jobApplicationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("获取职位申请信息")
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        JobApplicationEntity jobApplication = jobApplicationService.getById(id);

        return R.ok().put("jobApplication", jobApplication);
    }

    /**
     * 保存
     */
    @ApiOperation("保存职位申请")
    @PostMapping("/save")
    public R save(@RequestBody JobApplicationEntity jobApplication) {
        jobApplicationService.save(jobApplication);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改职位申请")
    @PutMapping("/update")
    public R update(@RequestBody JobApplicationEntity jobApplication) {
        jobApplicationService.updateById(jobApplication);

        return R.ok();
    }

    /**
     * 批量删除
     */
    @ApiOperation("批量删除职位申请")
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        jobApplicationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 指定删除
     */
    @ApiOperation("指定删除职位申请")
    @DeleteMapping("/deleteById/{id}")
    public R deleteById(@PathVariable("id") Long id) {
        jobApplicationService.removeById(id);

        return R.ok();
    }

}
